package com.vivek.guess.what.calculation;

import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.vivz.guess.what.type.Position;
import com.vivz.guess.what.vo.Guess;

public abstract class AbstractCalculation implements Calculation {

	protected final boolean isInputValid(final List<Guess> guesses, final Map<Character, Set<Position>> probabilityMap) {
		return !(guesses == null || guesses.isEmpty() || probabilityMap == null || probabilityMap.isEmpty());
	}

	protected final void removeEmptyPositionSets(final Map<Character, Set<Position>> probabilityMap) {

		if (probabilityMap == null || probabilityMap.isEmpty()) {
			return;
		}

		final Iterator<Entry<Character, Set<Position>>> iterator = probabilityMap.entrySet().iterator();
		while (iterator.hasNext()) {
			final Entry<Character, Set<Position>> entry = iterator.next();
			final Set<Position> postions = entry.getValue();
			if (postions == null || postions.isEmpty()) {
				iterator.remove();
			}
		}

	}

	public void calculate(final List<Guess> guesses, final Map<Character, Set<Position>> probabilityMap) {
		// TODO Auto-generated method stub

	}

}
